﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WbsEditor
{
    public partial class FadingUserControl : UserControl
    {
        public FadingUserControl()
        {
            InitializeComponent();
        }

        //protected override CreateParams CreateParams
        //{
        //    get
        //    {
        //        CreateParams cp = base.CreateParams;
        //        cp.ExStyle |= 0x00000020;
        //        return cp;
        //    }
        //}

        private int _opacity;

        public int Opacity
        {
            get { return _opacity; }
            set
            {
                _opacity = value;
                //this.InvalidateEx();
            }
        }

        //protected override void OnPaintBackground(PaintEventArgs e)
        //{
        //    Color bk = Color.FromArgb(Opacity, this.BackColor);
        //    e.Graphics.FillRectangle(new SolidBrush(bk), e.ClipRectangle);
        //}

        //protected override void OnPaintBackground(PaintEventArgs e)
        //{
        //    Color l_colBackground = Color.FromArgb(Opacity, this.BackColor);
        //    e.Graphics.FillRectangle(new SolidBrush(l_colBackground), e.ClipRectangle);

        //    Brush l_brFilled = new SolidBrush(Color.FromArgb(255, this.BackColor));

        //    foreach (Control l_ctrlCurrent in this.Controls)
        //        if (l_ctrlCurrent.Visible)
        //            e.Graphics.FillRectangle(l_brFilled, l_ctrlCurrent.Bounds);
        //}
        
        //protected void InvalidateEx()
        //{
        //    if (Parent == null)
        //        return;
        //    Rectangle rc = new Rectangle(this.Location, this.Size);
        //    Parent.Invalidate(rc, true);
        //}
        
        public void FadeIn()
        {
            Opacity = 50;
            Visible = true;
        }

        public void FadeOut()
        {
            Visible = false;
        }
    }
}
